Skip to content

MkCommandOutput

Show source on GitHub

Node to display the terminal output of a command.

Example: Regular

Jinja

{{ ["hatch", "--help"] | MkCommandOutput }}

Python

MkCommandOutput(['hatch', '--help'])

hatch --help /bin/sh: 1: hatch: not found

<div data-terminal>
  <span data-ty="input">hatch --help</span>
  <span data-ty>/bin/sh: 1: hatch: not found</span>
</div>
<div data-terminal>
  <span data-ty="input">hatch --help</span>
  <span data-ty>/bin/sh: 1: hatch: not found</span>
</div>

Bases: MkTemplate

__init__

__init__(call: Sequence[str], **kwargs: Any)

Parameters:

Name Type Description Default
call Sequence[str]

System call to make

required
kwargs Any

Keyword arguments passed to parent

{}
graph TD
  94721312194336["mkcommandoutput.MkCommandOutput"]
  94721308869584["mktemplate.MkTemplate"]
  94721311697232["mkcontainer.MkContainer"]
  94721308848336["mknode.MkNode"]
  94721311766592["node.Node"]
  140564252373184["builtins.object"]
  94721308869584 --> 94721312194336
  94721311697232 --> 94721308869584
  94721308848336 --> 94721311697232
  94721311766592 --> 94721308848336
  140564252373184 --> 94721311766592
/home/runner/work/mknodes/mknodes/mknodes/templatenodes/mkcommandoutput/metadata.toml
[metadata]
icon = "mdi:bash"
name = "MkCommandOutput"

[[resources.css]]
filename = "terminal.css"

[examples.regular]
condition = "{{ 'CI' | getenv }}"
title = "Regular"
jinja = """
{{ ["hatch", "--help"] | MkCommandOutput }}
"""

[output.html]
template = """
<div data-terminal>
  <span data-ty="input">{{ node.call | join(" ") }}</span>
  <span data-ty>{{ node.call | check_output(cwd=node.cwd) }}</span>
</div>
"""
mknodes.templatenodes.mkcommandoutput.MkCommandOutput
class MkCommandOutput(mktemplate.MkTemplate):
    """Node to display the terminal output of a command."""

    ICON = "material/bash"
    STATUS = "new"
    CSS = [resources.CSSFile("terminal.css")]

    def __init__(self, call: Sequence[str], **kwargs: Any):
        """Constructor.

        Args:
            call: System call to make
            kwargs: Keyword arguments passed to parent
        """
        self.call = call
        super().__init__("output/html/template", **kwargs)

    @property
    def cwd(self):
        return self.ctx.metadata.repository_path